var $validation = {
    settings: {
      username: 'username',
      email : 'email',
      fullname: 'fullname',
      birthday: 'birthday'
    },
    username : function($username) {
        return $validation.test(/^([a-z0-9_]{4,})+$/i, $username);
    },
    fullname : function($fullname) {
        return $validation.test(/(.+){4,}/i, $fullname);
    },
    email : function($email) {
        return $validation.test(/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/i, $email);
    },
    birthday:function($birthday){
        if($birthday == '-1'){
            return false;
        }
        return true;
    }
    ,
    test: function($reg, $str){
        return $reg.test($str);
    },
    run: function($tagId, $str){
        $isError = true;
        $txtErr = '';
        $arrErr ={
            username:'Username must be anpha bet and greater than 4 characters.', 
            email: 'Email is invalid', 
            fullname: 'Fullname must be greater 4 characters',
            required: 'This field is require'
        };
               
        if($tagId == $validation.settings.username){
            $isError = $validation.username($str);
            $txtErr = !$isError ? $arrErr.username : '';
        }
            
        if($tagId == $validation.settings.email){
            $isError = $validation.email($str);
            $txtErr = !$isError ? $arrErr.email : '';
        }
            
        if($tagId == $validation.settings.fullname){
            $isError = $validation.fullname($str);
            $txtErr = !$isError ? $arrErr.fullname : '';
        }
        
        if($tagId == $validation.settings.birthday){
            $isError = $validation.birthday($str);
            $txtErr = !$isError ? $arrErr.required : '';
        }
            
        $('#er_' + $tagId).html($txtErr);
            
        return $isError;
    }
};

